﻿using ProxyWrapper.CommonProxyService;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ServiceType : AppServices
{
    private DataTable databaseList = null;
    private ProxyWrapper.UserProxy.UserDetails _objUserObject = null;
    string _dbList = string.Empty;
    protected override void Page_Load(object sender, EventArgs e)
    {
        try
        {
            base.Page_Load(sender, e);
            if (Session["UserObject"] == null)
            {
                Response.Redirect("~/Default.aspx");
            }
            _objUserObject = ((ProxyWrapper.UserProxy.UserDetails)Session["UserObject"]);
            if (!Page.IsPostBack)
            {
                LoadDatabaseList();
            }
        }
        catch (Exception ex)
        {
        }
    }
    private void LoadDatabaseList()
    {
        StringBuilder sb = new StringBuilder();
        string selected = "";
        ProxyWrapper.DatabaseServiceWrapper _dbService = new ProxyWrapper.DatabaseServiceWrapper();
        List<ProxyWrapper.CommonProxyService.DatabaseDetails> _lstDB = _dbService.GetDBList(_objUserObject.ClientId);
        if (_lstDB != null && _lstDB.Count > 0)
        {
            sb.Append("<option selected disabled>Choose a Database</option>");
            foreach (DatabaseDetails item in _lstDB)
            {
                if (SrvDetails.DBId == item.DbId)
                    selected = "selected";
                else
                    selected = "";
                sb.Append("<option value=" + item.DbId.ToString() + " "+selected+">" + item.DBName + "</option>");
            }
        }
        else
        {
            sb.Append("<option selected disabled>No database created</option>");
        }

        _dbList = sb.ToString();
    }
    public string GetDatabaseString()
    {
        return _dbList;
    }
}